/**
 * 
 */
package vo;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import util.HibernateUtil;

/**
 * @author Saulo
 *
 */
public class ItemCompraDAO {

	//SALVAR ITEM COMPRA
		public void salvarItemCompra(ItemCompraVO itemCompra) {

			Transaction transaction = null;

			Session session = HibernateUtil.currentSession();
			transaction = session.beginTransaction();

			session.saveOrUpdate(itemCompra);

			transaction.commit();

		}
		
		//EXCLUIR ITEM COMPRA
		public void excluir(Integer idItComp) {
			Transaction transaction = null;

			Session session = HibernateUtil.currentSession();
			transaction = session.beginTransaction();

			session.delete(obter(idItComp));

			transaction.commit();
		}
		
		//OBTER ITEM COMPRA
		public ItemCompraVO obter(Integer idItComp) {
			Transaction transaction = null;

			Session session = HibernateUtil.currentSession();
			transaction = session.beginTransaction();

			Criteria criteria = session.createCriteria(ItemCompraVO.class);
			criteria.add(Restrictions.eq("id_it_comp", idItComp));

			ItemCompraVO itemCompra = (ItemCompraVO) criteria.uniqueResult();

			transaction.commit();

			return itemCompra;
		}

		public List<ItemCompraVO> consultarItensCompra(ItemCompraVO itemCompraConsulta) {
			// TODO Auto-generated method stub
			return null;
		}
}
